declare namespace fileWriter="java:java.io.FileWriter";
declare namespace bufferedWriter="java:java.io.BufferedWriter";
declare namespace printWriter="java:java.io.PrintWriter";

declare namespace javaXMLModule="java:io.FileWrite";

for $doc in "/home/sylamer/Desktop/xquery.log"
let $string := "Hallo Welt! < &amp; > This is me   "
return (
    <Test1> {
        javaXMLModule:init($doc),
        javaXMLModule:println($string),
        javaXMLModule:close()
    } </Test1>
    (:union
    <Test2>{
        let $cmd1 := printWriter:new(bufferedWriter:new(printWriter:new("/home/sylamer/Desktop/xquery2.log")), fn:true()),
            $cmd2 := printWriter:write($cmd1, "Hello World! &amp;"),
            $cmd3 := printWriter:close($cmd1)
        return ($cmd1, $cmd2, $cmd3)
    }</Test2>:)
)
              